Skip to content

fix(bedrock): always include toolConfig when messages contain toolUse/toolResult blocks#196

Merged
asdek merged 2 commits intovxcontrol:feature/next_releasefrom
manusjs:fix/bedrock-tool-config
Mar 20, 2026
Merged

fix(bedrock): always include toolConfig when messages contain toolUse/toolResult blocks#196
asdek merged 2 commits intovxcontrol:feature/next_releasefrom
manusjs:fix/bedrock-tool-config

Conversation

@manusjs
Copy link
Contributor

@manusjs manusjs commented Mar 11, 2026

What

Ensures toolConfig is always present in the Bedrock Converse API request when the message history contains toolUse or toolResult content blocks.

Fixes #160

Root Cause

The Bedrock Converse API requires toolConfig to be defined whenever a request or its history contains toolUse/toolResult blocks. The provider was only including toolConfig when new tool definitions were being added for the current turn, omitting it when tools were already embedded in history. This produced:

ValidationException: The toolConfig field must be defined when using toolUse
and toolResult content blocks.

Changes

  • Bedrock provider: Before sending the Converse request, scans the message chain for any toolUse/toolResult blocks. If found and toolConfig is nil/empty, injects a minimal toolConfig with the tools referenced in the chain.
  • bedrock_test.go: 4 new subtests — nil tools with tool-containing chain, empty tools slice with tool-containing chain, tools already set (no change), no tool blocks (no injection).

…/toolResult blocks

Ensure WithTools option is applied last in CallWithTools (consistent with
CallEx) so provider config options cannot accidentally overwrite restored
tool definitions. Add integration test covering the exact issue vxcontrol#160
scenario: chain with toolUse/toolResult blocks but no explicit tools in the
current turn.

Fixes vxcontrol#160

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@asdek asdek changed the base branch from master to feature/next_release March 20, 2026 10:16
Signed-off-by: Dmitry Ng <19asdek91@gmail.com>
@asdek asdek merged commit fcb8bd8 into vxcontrol:feature/next_release Mar 20, 2026
@asdek
Copy link
Contributor

asdek commented Mar 20, 2026

thank you for the PR!

@asdek asdek mentioned this pull request Mar 22, 2026
36 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: When using Bedrock, toolConfig is not defined causing failures.

2 participants